import cv2
import numpy as np

cv2.namedWindow("match")
image = cv2.imread("test.jpg")
target = cv2.imread("target.jpg")
imageGary = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
targetGary = cv2.cvtColor(target, cv2.COLOR_RGB2GRAY)
orb = cv2.ORB_create()
keyPoint1, des1 = orb.detectAndCompute(imageGary, None)
keyPoint2, des2 = orb.detectAndCompute(targetGary, None)
bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)
matches = bf.match(des1, des2)
matches = sorted(matches, key=lambda x: x.distance)
matchImage = cv2.drawMatches(image, keyPoint1, target, keyPoint2, matches[:100], (255, 0, 0), 2)

cv2.imshow("match", matchImage)
cv2.waitKey()
